<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .div2 {
            width: 50px;
            height: 50px;
            background-color: black;
            position: absolute;
            bottom: 0;
        }
        /* 从视口的底部移动到视口顶部 */
        @keyframes zxc {
            from {
                transform: translateY(100vh);
            }
            to {
                transform: translateY(-90vh);
            }
        }
        /*让js触发动画*/
        .animate {
            animation: zxc 1s forwards;
        }
    </style>
</head>
<body>
<div onclick="show()">aa</div>
<div class="div2">aa</div>

<script>
    function show() {
        const div = document.querySelector('.div2');
        //给div2添加动画
        div.classList.add('animate');
    }
</script>
</body>
</html>
